package com.software.seakdream.service;

import com.software.seakdream.entity.Favorite;
import com.software.seakdream.entity.History;
import com.software.seakdream.repository.FavoriteRepository;
import com.software.seakdream.repository.HistoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoriteServiceImpl implements FavoriteService{
    @Autowired
    private FavoriteRepository favoriteRepository;


    @Override
    public Favorite createFavorite(Favorite favorite) {
        favoriteRepository.createFavorite(favorite);
        return favorite;
    }

    @Override
    public Favorite createFavoriteW(Favorite favorite) {
        favoriteRepository.createFavoriteW(favorite);
        return favorite;
    }

    @Override
    public Boolean deleteFavorite(String userId, String audioId) {
        int result = favoriteRepository.deleteFavorite(userId, audioId);
        if (result == 0){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Boolean deleteFavoriteW(String userId, String whiteId1) {
        int result = favoriteRepository.deleteFavoriteW(userId, whiteId1);
        if (result == 0){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public List<Favorite> getUserFavourite(String userId) {
        List<Favorite> favorites = favoriteRepository.getUserFavourite(userId);
        return favorites;
    }
}
